<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>这是div</div>
<p id="p1">这是p1</p>
<p id="p2">这是p2</p>
<input type="text" value="">
<input type="button" value="按钮" onclick="f()">

<script>
    function f() {
        //得到div
        let d = document.querySelector("div")
        //得到文本框
        let i = document.querySelector("input")
        //把文本框里的内容取出并赋值给div
        d.innerText=i.value;

    }
</script>
</body>
</html>